﻿namespace WorkFlow.Engine.NSActivity.NSRoutes
{
    public class WfRouteController
    {
        /// <summary>
        ///     1.当打开一个活动时,检查该活动是否为路由活动,如果为路由活动,则进行路由,并将结果通知到用户
        ///     (被激活活动的ID,但没有被加载到ActivityController中),而是值以活动ID的形式通知
        ///     否则,如果为一般活动,这直接以活动ID通知,但不被加载到ActivityController中
        ///     以上方式都是但用户点击处理该活动时活动被激活.
        /// </summary>
        /// <param name="act"></param>
        /// <param name="inputValue"></param>
        /// <returns></returns>
        public static int GetCurrentAcitvityType(WfActivity act, int activatorID, int? inputValue = -1)
        {
            //判断该活动是否为路由活动
            if (act.MainType != WfFieldCode.DbMainRouteType) return act.MainType;
            switch (act.SubType)
            {
                case WfFieldCode.DbOrSplit:
                    new WfConditionTypeRoute().OrSplit(act,activatorID, inputValue);
                    break;

                case WfFieldCode.DbOrJoin:
                    new WfConditionTypeRoute().OrJoin(act,activatorID);
                    break;

                case WfFieldCode.DbAndSplit:
                    new WfParallelTypeRoute().AndSplit(act,activatorID, inputValue);
                    break;

                case WfFieldCode.DbAndJoin:
                    new WfParallelTypeRoute().AndJoin(act);
                    break;

                case WfFieldCode.DbXorSplit:
                    new WfExclusivenessTypeRoute().XorSplit(act,activatorID, inputValue);
                    break;

                case WfFieldCode.DbXorJoin:
                    new WfExclusivenessTypeRoute().XorJoin(act,activatorID);
                    break;
            }
            return WfFieldCode.DbMainRouteType;
        }
        }
}